package com.totoro.service;

import java.util.Collection;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.totoro.dao.BaseHibernateDao;
import com.totoro.dao.UserRoleDao;
import com.totoro.domain.User;
import com.totoro.domain.UserRole;

@Transactional
@Service
public class UserRoleService extends BaseService<UserRole, Integer>{

	private UserRoleDao userRoleDao;
	
	@Autowired
	@Override
	public void setBaseDao(BaseHibernateDao<UserRole, Integer> userRoleDao) {
		// TODO Auto-generated method stub
		this.baseDao = userRoleDao;
		this.userRoleDao = (UserRoleDao) userRoleDao;
	}
	
	public List<UserRole> list(String propertyName,Object value){
		return userRoleDao.list(propertyName, value);
	}
	
	public List<String> loadUserAuthorities(User user){
		return userRoleDao.loadUserAuthorities(user);
	}
	
	public Collection<GrantedAuthority> loadUserAuthorityByName(User user){
		return userRoleDao.loadUserAuthorityByName(user);
	}

}
